﻿Imports DataDynamics.ActiveReports 
Imports DataDynamics.ActiveReports.Document 

Public Class R030401
#Region "変数"

    ''' <summary>
    ''' ページフラグ
    ''' </summary>
    ''' <remarks></remarks>
    Private blnNewPage As Boolean = False

    Dim rowcounts As Integer = -1

    Dim rows As Integer = 0

    Dim line82long As Boolean = False

    Dim totalsum As Integer = 0
#End Region

    Private Sub R030401_FetchData(sender As Object, eArgs As DataDynamics.ActiveReports.ActiveReport.FetchEventArgs) Handles Me.FetchData
        rows += 1
    End Sub

    Private Sub R030401_PageStart(sender As Object, e As System.EventArgs) Handles Me.PageStart

        If rowcounts > 33 Then
            If rows > rowcounts - 32 Then
                line82long = False
                PageFooter.Height = 4.81 / 2.54
            Else

                line82long = True
                PageFooter.Height = 0.961 / 2.54
            End If
        End If


        If rowcounts < 33 Then

            If rowcounts < 22 Then

                line82long = False
                PageFooter.Height = 4.801 / 2.54
            Else
                line82long = True
                PageFooter.Height = 0.961 / 2.54
            End If

        End If

    End Sub

    Private Sub R030401_ReportStart(sender As Object, e As System.EventArgs) Handles Me.ReportStart
        Dim dt As DataTable
        dt = Me.DataSource
        rowcounts = dt.Rows.Count

        If rowcounts > 21 And rowcounts < 30 Then
            For i As Integer = 1 To 8
                dt.Rows.Add()
            Next
            Me.DataSource = dt
        Else
            Dim rest As Integer = 0
            Dim rowtemp As Integer = rowcounts - 29
            rest = rowtemp Mod 37

            If rest > 29 And rest < 38 Then
                For i As Integer = 1 To 8
                    dt.Rows.Add()
                Next

                Me.DataSource = dt
            End If
        End If

        rowcounts = dt.Rows.Count
    End Sub


    Private Sub GroupHeader1_Format(sender As System.Object, e As System.EventArgs) Handles GroupHeader1.Format
        blnNewPage = True
        totalsum = 0
    End Sub

    Private Sub GroupHeader2_Format(sender As System.Object, e As System.EventArgs) Handles GroupHeader2.Format
        If blnNewPage = True Then
            GroupHeader2.Height = 0
            blnNewPage = False
        End If
    End Sub

    Private Sub PageFooter_Format(sender As System.Object, e As System.EventArgs) Handles PageFooter.Format
        If line82long Then
            Me.Line82.X1 = Me.Line60.X1
            Me.Line82.X2 = Me.Line70.X1
        End If
        If IsNumeric(txttaxrate.Text) Then
            txtpagetax.Text = CInt(txtpagesum.Text * txttaxrate.Text / 100)
        End If
        totalsum += CInt(txtpagetax.Text) + CInt(txtpagesum.Text)
        txtalltotal.Text = totalsum
        txttaxrate.Text += "%"

    End Sub
End Class
